﻿Public Class TMyProcedures
    Inherits TCustomMyObjects

    Friend Sub New(ByVal AOwner As TMyDatabase)
        MyBase.New(AOwner)
    End Sub

    Public Overrides Sub Refresh()
        Dim item As TMyProcedure
        _List.Clear()
        MyQuery.Clear()
        MyQuery.SQL.AppendLine("select")
        MyQuery.SQL.AppendLine(" SPECIFIC_NAME")
        MyQuery.SQL.AppendLine(",ROUTINE_CATALOG")
        MyQuery.SQL.AppendLine(",ROUTINE_SCHEMA")
        MyQuery.SQL.AppendLine(",ROUTINE_NAME")
        MyQuery.SQL.AppendLine(",ROUTINE_TYPE")
        MyQuery.SQL.AppendLine(",DATA_TYPE")
        MyQuery.SQL.AppendLine(",CHARACTER_MAXIMUM_LENGTH")
        MyQuery.SQL.AppendLine(",CHARACTER_OCTET_LENGTH")
        MyQuery.SQL.AppendLine(",NUMERIC_PRECISION")
        MyQuery.SQL.AppendLine(",NUMERIC_SCALE")
        MyQuery.SQL.AppendLine(",CHARACTER_SET_NAME")
        MyQuery.SQL.AppendLine(",COLLATION_NAME")
        MyQuery.SQL.AppendLine(",DTD_IDENTIFIER")
        MyQuery.SQL.AppendLine(",ROUTINE_BODY")
        MyQuery.SQL.AppendLine(",ROUTINE_DEFINITION")
        MyQuery.SQL.AppendLine(",EXTERNAL_NAME")
        MyQuery.SQL.AppendLine(",EXTERNAL_LANGUAGE")
        MyQuery.SQL.AppendLine(",PARAMETER_STYLE")
        MyQuery.SQL.AppendLine(",IS_DETERMINISTIC")
        MyQuery.SQL.AppendLine(",SQL_DATA_ACCESS")
        MyQuery.SQL.AppendLine(",SQL_PATH")
        MyQuery.SQL.AppendLine(",SECURITY_TYPE")
        MyQuery.SQL.AppendLine(",CREATED")
        MyQuery.SQL.AppendLine(",LAST_ALTERED")
        MyQuery.SQL.AppendLine(",SQL_MODE")
        MyQuery.SQL.AppendLine(",ROUTINE_COMMENT")
        MyQuery.SQL.AppendLine(",DEFINER")
        MyQuery.SQL.AppendLine(",CHARACTER_SET_CLIENT")
        MyQuery.SQL.AppendLine(",COLLATION_CONNECTION")
        MyQuery.SQL.AppendLine(",DATABASE_COLLATION")
        MyQuery.SQL.AppendLine("from")
        MyQuery.SQL.AppendLine(" information_schema.routines")
        MyQuery.SQL.AppendLine("where")
        MyQuery.SQL.AppendLine("routine_schema=?routine_schema")
        MyQuery.SQL.AppendLine("and routine_type='PROCEDURE'")
        MyQuery.SQL.AppendLine("order by")
        MyQuery.SQL.AppendLine(" routine_name")
        MyQuery.DeclareAndSet("routine_schema", Me.DatabaseName)
        MyQuery.Execute()
        While Not MyQuery.Eof
            item = New TMyProcedure(Me, MyQuery.FieldAsString("routine_name"))
            item._SpecificName = MyQuery.FieldAsString("specific_name")
            item._RoutineCatalog = MyQuery.FieldAsString("routine_catalog")
            item._RoutineSchema = MyQuery.FieldAsString("routine_schema")
            item._RoutineName = MyQuery.FieldAsString("routine_name")
            item._RoutineType = MyQuery.FieldAsString("routine_type")
            item._DataType = MyQuery.FieldAsString("data_type")
            item._CharacterMaximumLength = MyQuery.FieldAsInteger("character_maximum_length")
            item._CharacterOctetLength = MyQuery.FieldAsInteger("character_octet_length")
            item._NumericPrecision = MyQuery.FieldAsInteger("numeric_precision")
            item._NumericScale = MyQuery.FieldAsInteger("numeric_scale")
            item._CharacterSetName = MyQuery.FieldAsString("character_set_name")
            item._CollationName = MyQuery.FieldAsString("collation_name")
            item._DtdIdentifier = MyQuery.FieldAsString("dtd_identifier")
            item._RoutineBody = MyQuery.FieldAsString("routine_body")
            item._RoutineDefinition = MyQuery.FieldAsString("routine_definition")
            item._ExternalName = MyQuery.FieldAsString("external_name")
            item._ExternalLanguage = MyQuery.FieldAsString("external_language")
            item._ParameterStyle = MyQuery.FieldAsString("parameter_style")
            item._IsDeterministic = MyQuery.FieldAsString("is_deterministic")
            item._SqlDataAccess = MyQuery.FieldAsString("sql_data_access")
            item._SqlPath = MyQuery.FieldAsString("sql_path")
            item._SecurityType = MyQuery.FieldAsString("security_type")
            item._Created = MyQuery.FieldAsDateTime("created")
            item._LastAltered = MyQuery.FieldAsDateTime("last_altered")
            item._SqlMode = MyQuery.FieldAsString("sql_mode")
            item._RoutineComment = MyQuery.FieldAsString("routine_comment")
            item._Definer = MyQuery.FieldAsString("definer")
            item._CharacterSetClient = MyQuery.FieldAsString("character_set_client")
            item._CollationConnection = MyQuery.FieldAsString("collation_connection")
            item._DatabaseCollation = MyQuery.FieldAsString("database_collation")
            _List.Add(item)
            MyQuery.MoveNext()
        End While
        MyQuery.Close()
    End Sub


End Class
